-- genie, https://github.com/bkaradzic/GENie
-- known working version
-- https://github.com/bkaradzic/bx/blob/51f25ba638b9cb35eb2ac078f842a4bed0746d56/tools/bin/windows/genie.exe

MINGW_ACTION = 'gmake'

if _ACTION == 'clean' then
    os.rmdir('./build')
    os.rmdir('./bin')
    os.rmdir('./obj_vs')
    os.rmdir('./obj_' .. MINGW_ACTION)
end

if _ACTION == MINGW_ACTION then
    -- need a msys2 with clang
    premake.gcc.cc   = 'clang'
    premake.gcc.cxx  = 'clang++'
    premake.gcc.ar   = 'llvm-ar'
    premake.llvm = true
end

local ROOT = os.getcwd()
print(ROOT)

solution('GUI')
    location("./build")
    configurations({'Debug', 'Release'})
    platforms({'x32', 'x64'})

    project('GUI')
        language("C")
        files({'src/**.c', 'inc/**.h', 'src/**.cpp', 'inc/**.hpp'})
        links({'windowscodecs', 'dxguid', 'Dwrite', 'd2d1', 'd3d11', 'Imm32'}) 

        configuration('Debug')
			flags({'ExtraWarnings', 'Symbols'})
            defines({'_DEBUG'})
            kind("SharedLib")

        configuration('Release')
			flags({"Optimize"})            
			flags({'Symbols'}) -- keep the debug symbols for development
            defines({'NDEBUG'})
            kind("SharedLib")

        configuration("vs*")
            defines({"_CRT_SECURE_NO_WARNINGS"})
            flags({'NoManifest'})
            kind("SharedLib") -- We don't need the console window in VS as we use OutputDebugString(). StaticLib/SharedLib/WindowedApp/ConsoleApp
            --buildoptions({'/wd"4214"'})
			--linkoptions({'/ENTRY:"mainCRTStartup" /SAFESEH:NO'})
			-- characterset("MBCS")
            includedirs({'inc'})
            objdir('obj_vs')

        configuration({'x32', 'vs*'})
            -- defines would be passed to resource compiler for whatever reason
            -- and ONLY can be put here not under 'configuration('x32')' or it won't work
            defines({'X32'})
            includedirs({'inc'})

        configuration({'x64', 'vs*'})
            defines({'X64'})
            includedirs({'inc'})
